#include "MACROs_UNDEF.h"

#define PROPERTY_CHANGE_EVENT_AUTO \
        protected:\
            void OnPropertyChanged(Platform::String^ propertyName)\
            {\
				PropertyChanged(this, ref new Windows::UI::Xaml::Data::PropertyChangedEventArgs(propertyName));\
            }\
        public:\
            virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged;

#define PROPERTY_CHANGE_EVENT_EXPLICIT \
        private:\
            bool _isPropertyChangedObserved;\
            event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ _privatePropertyChanged;\
        protected:\
            void OnPropertyChanged(Platform::String^ propertyName)\
            {\
				if (_isPropertyChangedObserved) {\
					PropertyChanged(this, ref new Windows::UI::Xaml::Data::PropertyChangedEventArgs(propertyName));\
				}\
            }\
        public:\
            virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged\
            {\
                virtual Windows::Foundation::EventRegistrationToken add(Windows::UI::Xaml::Data::PropertyChangedEventHandler^ e)\
                {\
					_isPropertyChangedObserved = true;\
					return _privatePropertyChanged += e;\
                }\
                virtual void remove(Windows::Foundation::EventRegistrationToken t)\
                {\
                    _privatePropertyChanged -= t;\
                }\
        protected:\
                virtual void raise(Platform::Object^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e)\
                {\
					_privatePropertyChanged(this, e);\
                }\
            }

//#define PROPERTY_CHANGE_EVENT PROPERTY_CHANGE_EVENT_AUTO
#define PROPERTY_CHANGE_EVENT PROPERTY_CHANGE_EVENT_EXPLICIT
